<template>
  <div>
    <van-field
      v-model="text"
      :label="label"
      :type="type"
      :placeholder="placeholder"
      :rule="rule"
    />
  </div>
</template>
<script>
export default {
  props: ['label', 'type', 'placeholder', 'rule'],
  data: () => ({
    text: ''
  }),
  methods: {
    handlerulg() {
      // /* 正则 */
      // const rue = new RegExp(this.rule)
      /* 判断 */
      // if (rue.test(this.text)) {
      //   // console.log(111);
      //   this.$emit('inptuChange', this.text)
      // }
      this.$emit('inptuChange', this.text)
    }
  },
  /* 对data里面的数据进行监听 */
  watch: {
    text() {
      this.handlerulg()
    }
  }
}
</script>
<style lang="less" scoped>
</style>